package com.changgou.backend.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.goods.feign.PopularFeign;
import com.changgou.goods.pojo.Sku;
import com.changgou.order.feign.OrderFeign;
import com.changgou.order.feign.ReportOrderFeign;
import com.changgou.user.feign.ReportUserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/wreport")
public class ReportController {

    @Autowired
    private ReportOrderFeign reportOrderFeign;

    @Autowired
    private ReportUserFeign reportUserFeign;

    @Autowired
    private PopularFeign popularFeign;



    @GetMapping("/orderReport")
    @ResponseBody
    public Result orderReport(){
        List<Map<String, String>> mapList = reportOrderFeign.findOrder().getData();
        return new Result(true, StatusCode.OK,"查询成功",mapList);
    }

    @GetMapping("/userReport")
    @ResponseBody
    public Result userReport(){
        Map map = reportUserFeign.findUser().getData();
        return new Result(true, StatusCode.OK,"查询成功",map);
    }

    @GetMapping("/profitReport")
    @ResponseBody
    public Result profitReport(){
        Map map = reportOrderFeign.profitReport().getData();
        return new Result(true, StatusCode.OK,"查询成功",map);
    }

    @GetMapping("/popularReport")
    @ResponseBody
    public Result popularReport(){
        Map map = popularFeign.popularReport().getData();
        System.out.println(map);
        return new Result(true, StatusCode.OK,"查询成功",map);
    }

}
